package com.lxw.report.meta.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

/**
 * @author lxw
 */

public enum UserIdentityEnum {
    ADMIN(1, "管理员"),
    USER(2, "用户"),;

    @EnumValue
    private final int code;

    private String desc;

    UserIdentityEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static boolean isAdmin(int code){
        if(code==1){
            return true;
        }else{
            return false;
        }
    }

    public static boolean isAdmin(UserIdentityEnum userIdentityEnum){
        if(userIdentityEnum==ADMIN){
            return true;
        }else{
            return false;
        }
    }

    public static UserIdentityEnum getByCode(int code){
        for (UserIdentityEnum identityEnum : UserIdentityEnum.values()) {
            if (identityEnum.getCode().intValue()==code) {
                return identityEnum;
            }
        }
        return null;
    }
}
